<template>
    <el-card class="contanier">
        <div slot="header" class="clearfix">
            <span>用户留言</span>
        </div>
        <div>
            <div v-for="(item, index) in worddata" :key="item.id" class="box">
                <div class="top">
                    <div class="img">
                        <img
                            src="https://img1.baidu.com/it/u=4256350010,1509363888&fm=253&fmt=auto&app=138&f=JPEG?w=400&h=400" />
                    </div>
                    <div class="right">
                        <div class="name">{{ item.username }}</div>
                        <div class="date">{{ item.date }}</div>
                    </div>
                   
                </div>
                <div class="center">
                    {{ item.content }}
                </div>
            </div>
        </div>
    </el-card>
</template>

<script>

import { getworddata } from "@/api/word";

export default {
    data() {
        return {
            worddata: []
        }
    },
    mounted() {
        this.initdata()
    },
    methods: {
        async initdata() {
            let result = await getworddata();
            if (result.status == 0) {
                this.worddata = result.data
                console.log(result.data);
            }
        }
    }
}
</script>

<style scoped>
.contanier {
    margin: 30px;
    width: 45%;
    height: 500px;
    overflow-y: scroll;
}
.box {
    margin-left: 30px;
    margin-right: 30px;
    margin-bottom: 15px;
    .top {
      display: flex;

      img {
        width: 50px;
        height: 50px;
        border-radius: 50%;
      }
      .right {
        display: flex;
        justify-content: center;
        flex-direction: column;
        /* align-items: center; */
        margin-left: 15px;
        .name {
          font-size: 20px;
          color: #ffbc42;
        }
        .date {
          color: #666;
        }
      }
      
    }
    .center {
      color: #666;
      font-size: 14px;
      margin-top: 5px;
      height: auto;
    }
  }
</style>